package com.huadao.cart_ccs.data.bo;

import com.huadao.cart_ccs.R;
import com.huadao.cart_ccs.common.deviceController.TemperatureController;
import com.huadao.cart_ccs.main.CartApplication;

/**
 * 温度
 */
public class TemperatureBO extends BaseBO {

    public static final byte ModularType_Temperature =0x3;
    public static final byte temperature_NO1 = 0x01;

    public static final byte read= (byte) 0xFF;//读
    public static final byte write= (byte) 0xBB;//写
    public static final byte stop= (byte) 0xAA;//停止加热

    private double temperature;

    @Override
    protected String getModularTypeStr() {
        return CartApplication.getInstance().getString(R.string.temperature);
    }

    public double getTemperature() {
        return temperature;
    }

    public void setTemperature(double temperature) {
        this.temperature = temperature;
    }

    @Override
    protected String getOrderStr() {
        String orderStr = null;
        if (order == read) {
            orderStr = CartApplication.getInstance().getString(R.string.read);
        } else if (order == write) {
            orderStr = CartApplication.getInstance().getString(R.string.write);
        }else if(order==stop){
            orderStr = CartApplication.getInstance().getString(R.string.stopHeat);
        }
        return orderStr;
    }

    @Override
    protected String getOrderContentStr() {
        if(order==stop){
            return super.getOrderContentStr();
        }
        StringBuilder stringBuilder = new StringBuilder();
        stringBuilder.append(" 温度:");
        stringBuilder.append(temperature);
        stringBuilder.append("度");
        stringBuilder.append(" 校准温度:");
        stringBuilder.append(getAdjustTemperature());
        stringBuilder.append("度");
        return stringBuilder.toString();
    }

    //校准后的值
    public double getAdjustTemperature() {
        return TemperatureController.getInstance().calculatedTemperature(temperature);
    }
}
